package com.model.defaults.tabsheet.entities;

import java.util.Map;

import org.hibernate.Session;

import com.core.utils.GlobalConstants;
import com.model.ActionScript;
import com.model.KeyValue;
import com.model.TabSheetItem;
import com.model.UserContextName;


public class ModelDefaultTabsheetAdministration {

	public static void createTabsheetItemsAdministration ( Session session,
	                                                       Map <String, UserContextName> userContexts ) {

		TabSheetItem pojo = null;
		UserContextName visibleInContextName_1 = null;
		UserContextName userContextNameToExecute = null;
		ActionScript actionScript = null;
		KeyValue actionScriptParam = null;

		actionScriptParam = new KeyValue("selectedTab", "selectedTab=1");
		session.save(actionScriptParam);

		actionScript = new ActionScript();
		actionScript.setActionScriptText("%s?{selectedTab}", GlobalConstants.SERVLET_ADMINISTRATION);
		actionScript.setActionScriptType("servlet");
		actionScript.getParams().add(actionScriptParam);
		session.save(actionScript);

		visibleInContextName_1 = userContexts.get(GlobalConstants.USERCONTEXT_ADMINISTRATION);
		userContextNameToExecute = userContexts.get(GlobalConstants.USERCONTEXT_USERSLIST);

		pojo = new TabSheetItem();
		pojo.setName("tabsheet.administration.users");
		pojo.getUserContextNameVisibleIn().add(visibleInContextName_1);
		pojo.setUserContextNameToExecute(userContextNameToExecute);
		pojo.setJspNameInContext("BrowseAdministration#Summary");
		pojo.setServletNameToExecute(GlobalConstants.SERVLET_ADMINISTRATION);
		pojo.setJspNameInContext("details/tabUsersList.jsp");
		pojo.setActionScript(actionScript);
		session.save(pojo);


		/**
		 * User Groups
		 */

		actionScriptParam = new KeyValue("selectedTab", "selectedTab=2");
		session.save(actionScriptParam);

		actionScript = new ActionScript();
		actionScript.setActionScriptText("%s?{selectedTab}", GlobalConstants.SERVLET_ADMINISTRATION);
		actionScript.setActionScriptType("servlet");
		actionScript.getParams().add(actionScriptParam);
		session.save(actionScript);

		visibleInContextName_1 = userContexts.get(GlobalConstants.USERCONTEXT_ADMINISTRATION);
		userContextNameToExecute = userContexts.get(GlobalConstants.USERCONTEXT_GROUPSLIST);
		pojo = new TabSheetItem();
		pojo.setName("tabsheet.administration.groups");
		pojo.getUserContextNameVisibleIn().add(visibleInContextName_1);
		pojo.setJspNameInContext("details/tabUserGroups.jsp");
		pojo.setServletNameToExecute(GlobalConstants.SERVLET_ADMINISTRATION);
		pojo.setUserContextNameToExecute(userContextNameToExecute);
		pojo.setActionScript(actionScript);
		session.save(pojo);

		/**
		 * User Roles
		 */

		actionScriptParam = new KeyValue("selectedTab", "selectedTab=3");
		session.save(actionScriptParam);

		actionScript = new ActionScript();
		actionScript.setActionScriptText("%s?{selectedTab}", GlobalConstants.SERVLET_ADMINISTRATION);
		actionScript.setActionScriptType("servlet");
		actionScript.getParams().add(actionScriptParam);
		session.save(actionScript);

		visibleInContextName_1 = userContexts.get(GlobalConstants.USERCONTEXT_ADMINISTRATION);
		userContextNameToExecute = userContexts.get(GlobalConstants.USERCONTEXT_ROLESLIST);
		pojo = new TabSheetItem();
		pojo.setName("tabsheet.administration.roles");
		pojo.getUserContextNameVisibleIn().add(visibleInContextName_1);
		pojo.setUserContextNameToExecute(userContextNameToExecute);
		pojo.setJspNameInContext("details/tabUserRoles.jsp");
		pojo.setServletNameToExecute(GlobalConstants.SERVLET_ADMINISTRATION);
		pojo.setActionScript(actionScript);
		session.save(pojo);

		/**
		 * Custom DB actions
		 */

		actionScriptParam = new KeyValue("selectedTab", "selectedTab=4");
		session.save(actionScriptParam);

		actionScript = new ActionScript();
		actionScript.setActionScriptText("%s?{selectedTab}", GlobalConstants.SERVLET_ADMINISTRATION);
		actionScript.setActionScriptType("servlet");
		actionScript.getParams().add(actionScriptParam);
		session.save(actionScript);

		visibleInContextName_1 = userContexts.get(GlobalConstants.USERCONTEXT_ADMINISTRATION);
		pojo = new TabSheetItem();
		pojo.setName("tabsheet.administration.dbactions");
		pojo.getUserContextNameVisibleIn().add(visibleInContextName_1);
		userContextNameToExecute = userContexts.get(GlobalConstants.USERCONTEXT_ADMINISTRATION);
		pojo.setJspNameInContext("details/tabDBActions.jsp");
		pojo.setServletNameToExecute(GlobalConstants.SERVLET_ADMINISTRATION);
		pojo.setActionScript(actionScript);
		session.save(pojo);

	}

}
